﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.ServiceLocation;
using XWord.GUI.Presenters.Interface;
using XWord.WPF.ApplicationFramework.Threads;

namespace XWord.GUI
{
    public interface IRibbonDockWindowCycle
    {
        void InitTab();

        void InitExploer();
    }

    public class RibbonDockWindowCycle : IRibbonDockWindowCycle
    {
        IServiceLocator container = ServiceLocator.Current;
        public void InitTab()
        {
            foreach (var item in container.GetAllInstances<ITabPresenter>().OrderBy(e => e.Index))
            {
                item.ShowRibbon();
            }
        }

        public void InitExploer()
        {
            foreach (var item in container.GetAllInstances<IExporerPresenter>())
            {
                item.Show();
            }
        }

        public static void Run()
        {
            UIThread.BeginInvoke(() =>
            {
                var cycle = new RibbonDockWindowCycle();
                cycle.InitTab();
                cycle.InitExploer();
            });
        }
    }

}
